package com.globallogic.training.javase.university.subject;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;


/**
 * This class represents the list of subjects which are planned
 * for specific group to cover during the semester or year.
 * @author Ivan Moisiienko
 * @version 0.2 2013/05/13
 */
public class Curriculum {
	
	private Set<Subject> subjects = new TreeSet<Subject>();
	
	public boolean addSubject(Subject subject) {
		if (subject == null) {
			return false;
		}
		
		return subjects.add(subject);
	}
	
	public boolean removeSubject(Subject subject) {
		return subjects.remove(subject);
	}
	
	public Subject getSubject(Subject subject) {
		for (Iterator<Subject> it = subjects.iterator(); it.hasNext(); ) {
	        Subject sub = it.next();
	        if (sub.equals(subject)) {
	        	return sub;
	        }
	    }
		return null;
	}
	
	public Set<Subject> getSubjects() {
		return subjects;
	}
	
}
